<?php
require 'Model.php';
	class CommentModel extends Model{
		function __Construct(){
			parent::__Construct();
			$this->mod = 'comments';
		}
		function getList(){
			$data = array();
			$sql = "select * from {$this->mod}";
		    $comments = $this->conn->query($sql);
		    foreach($comments as $c){
		    $sql ="select song from musics where sid={$c['sid']}";
		    $musics= $this->conn->query($sql);
		    foreach ($musics as $m) {
		    			    $cc['song']=$m['song'];
		    }
		    $cc['cid']=$c['cid'];
		    $cc['cdate']=$c['cdate'];
		    $cc['content']=$c['content'];
		    $data[]=$cc;
}
			return $data;
		}
				function delcomment($id){
			$sql = "delete from {$this->mod} where cid=".$id;
			$result = $this->conn->query($sql);
			return $result;
		}

	}



	?>
